Add support for NOT NULL columns and foreign keys with ON DELETE#36
Conversation
674c984 to
d2ae3f8
Compare
|
Czesc Macieju, sorry for the late reply and thanks for the contribution! Could you please update README.MD, the section "Mapping customization" with the new keywords? You can freely use C++17 and The The reason why I haven't had the foreign key support, especially with cascading, is that the entity cache in the OR-mapper has to be updated as well on the cascade action. Imagine you have the following: Now, I read all provinces and towns in the OR-Mapper, and both class instances are created as C++ objects and cached inside the OR mapper in QOrmEntityInstanceCache. And then I execute To deal with the first part, I had a prototype implementation of Then I mitigated the problem at least for SQLite > 3.35, because there is a The second part of the problem is that we have to find out which entities are referenced by the removed ones and purge them from cache as well. Without the cascading it is the programmer's job to cleanup the referenced Towns before even executing the If the OR mapper already does the cascading to clean up its cache, then ON DELETE in the FK definition becomes unneccessary:
What are your thoughts on this? Cheers & dzieki bardzo |
|
Cześć :) Sorry for the late response too, I was sure I checked here and somehow missed it. That makes perfect sense, I completely missed the issue (good thing you caught it instead of me finding out after using it 😅 ). Cascade at DB level doesn't make much sense, I'll remove it. ORM-level cascade would be rather hard to fit with the current API, because I think foreign keys for data integrity would still be good though, right? |
ec455d6 to
a226fe1
Compare
a226fe1 to
6ddc724
Compare
6ddc724 to
9cbc66f
Compare
|
Ok, @dpurgin I've updated the changes. In the meantime I needed UNIQUE constraints too and found two escape issues - happy to split off into another one if you want to keep this PR smaller.
|
9cbc66f to
095bca7
Compare
|
Thanks for your work! I've tested it with other projects and it looks good! |
Hello, hope you don't mind contributions without prior discussion - I've added two features I needed. I tried to follow the current code style and approach.
Oh and I've put them both in one PR because they interact, but if you prefer squashing PRs I'd be happy to put them separately (otherwise I have no problems rebasing my changes after any comments you might have to enable a fast-forward merge).
The FK on relations is implicit - gets created if ON_DELETE is set. This felt in-line with the current approach, but I'm happy to make it explicit too.